import java.util.Scanner;

/**
 * Created by forcht on 2018/4/27.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int[] a=new int[n];
        f(a,0,n);

    }
    static void f(int[] a,int cur,int n){
        if(cur>=n){
            for(int i=0;i<n;i++){
                System.out.print(a[i]);
            }
            System.out.println();
            return;
        }
        for(int i=1;i<=n;i++){
            boolean flag=true;
            for(int j=0;j<cur;j++){
                if(a[j]==i){
                    flag=false;
                    break;
                }
            }
            if (flag){
                a[cur]=i;
                f(a,cur+1,n);
            }
        }
    }
}
